package com.game.test;

import java.awt.Graphics2D;

import com.game.core.GameAction;
import com.game.core.GameCore;
import com.game.core.InputManager;
import com.game.util.Drag;

public class GameManager extends GameCore{
	
	InputManager inputManager;
	GameAction click;
	GameAction exit;
	@Override
	public void init() {
		super.init();
		
		click=new GameAction("click",GameAction.DETECT_INITAL_PRESS_ONLY);
		exit=new GameAction("exit",GameAction.DETECT_INITAL_PRESS_ONLY);
		
		inputManager = new InputManager(screen.getWindow());
		//inputManager.mapToMouse(click, InputManager.MOUSE_BUTTON_1);
		inputManager.mapToMouse(exit, InputManager.MOUSE_BUTTON_3);
		
		Drag.bind(screen.getWindow());
	}
	
	@Override
	public void draw(Graphics2D g) {
		g.clearRect(0, 0,screen.getWidth(), screen.getHeight());
	}
	
	private void checkInput(long elapsedTime) {
		if(click.isPressed()){
			screen.setFullScreen(!screen.isFullScreen());
		}else if(exit.isPressed()){
			System.exit(0);
		}
	}
	
	@Override
	public void update(long elapsedTime) {
		checkInput(elapsedTime);
		
	}
	
	public static void main(String[] args) {
		new GameManager().run();
	}
}
